1 2 module gamescript.entry; 3 import hip.api; 4 import hip.assets.texture; 5 import hip.assets.image; 6 7 /** 8 * Call `dub` to generate the DLL, after that, just execute `dub -c run` for starting your project 9 */ 10 class MainScene : AScene, IHipPreloadable 11 { 12 mixin Preload; 13 HipTexture tex; 14 15 /** Constructor */ 16 override void initialize() 17 { 18 Image img = new Image(256, 256, 1); 19 for(int i = 0; i < 256; i++) 20 { 21 for(int x = 0; x < 256; x++) 22 { 23 size_t idx = i*256+x; 24 img.pixels[idx] = i < 50 ? 0xff : 0; 25 } 26 } 27 tex = new HipTexture(img, HipResourceUsage.Dynamic); 28 29 for(int y = 50; y < 100; y++) 30 { 31 for(int x = 0; x < 256; x++) 32 { 33 size_t idx = y*256+x; 34 img.pixels[idx] = 0x44; 35 } 36 } 37 tex.updatePixels(0, 50, 256, 50, img.pixels[50*256..$]); 38 39 } 40 /** Called every frame */ 41 override void update(float dt) 42 { 43 44 } 45 /** Renderer only, may not be called every frame */ 46 override void render() 47 { 48 49 drawText("You can start using the D Scripting API Here!", 400, 300, 2.0, HipColor.white, 50 HipTextAlign.center 51 ); 52 53 drawTexture(tex, 200, 200); 54 55 } 56 /** Pre destroy */ 57 override void dispose() 58 { 59 60 } 61 override void onResize(uint width, uint height){} 62 } 63 64 mixin HipEngineMain!MainScene;